module breathLed (
    input sys_clk,
    input sys_rst,
    output reg led_out
);

parameter clkdiver = 5000000/1000;

reg [15:0] counter;

reg [15:0] clk_pulse = 16'b0;

reg clk_flag;

reg [3:0] cnt_pul = 1;

always @(posedge sys_clk) begin
    if (sys_rst == 1)
        counter <= 0;
    else if(counter == clkdiver) begin
        counter <= 0;
        clk_flag <= 1;
    end 
    else  begin
        counter <= counter + 1;
        clk_flag <= 0;
    end
    

end

always @(posedge sys_clk) begin
    if (sys_rst == 1) begin
        led_out <= 1'b0;
    end
    else if (counter < clk_pulse) begin
        led_out <= 1'b1;
    end
    else begin
        led_out <= 1'b0;
    end
end

always @(posedge clk_flag ) begin
    if (sys_rst == 1)
        cnt_pul <= 0;
    else if(cnt_pul == 9) 
        cnt_pul <= 1;  
    else     
        cnt_pul <= cnt_pul + 1;

end


always @(posedge clk_flag ) begin
    if (sys_rst == 1)
        clk_pulse <= 0;
    else     
        clk_pulse <= cnt_pul * clkdiver / 10;
end


endmodule